package com.pengweiwei.androidzygote.main.ui;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.fragment.app.Fragment;

import com.pengweiwei.androidzygote.R;
import com.pengweiwei.androidzygote.game.HomeGameFragment;
import com.pengweiwei.androidzygote.mine.MineFragment;
import com.pengweiwei.androidzygote.video.HomeQualityFragment;
import com.pengweiwei.androidzygote.video.HomeVideoFragment;
import com.putong35.common.commonui.RadioButtonBottomTabFragment;
import com.putong35.common.customviews.BadgeRadioButton;

import java.util.ArrayList;
import java.util.List;

/**
 * 主界面的fragment
 *
 * @Author: PV
 * @E-mail: pengveivei@sina.cn
 * @CreateDate: 2016/6/24 15:47
 * @Version: 1.0.0
 */
public class MainBottomFragment extends RadioButtonBottomTabFragment {


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = super.onCreateView(inflater, container, savedInstanceState);

       /* Button btn = (Button) inflater.inflate(R.layout.main_bottom_button, container, false);
        addButton(btn, 2);

        setRadioButtonInterruptCheckedListener(3, new BadgeRadioButton.OnInterruptCheckedListener() {
            @Override
            public boolean onInterruptChecked(View view, boolean checked) {
                return false; // interrupt checked event
            }
        });

        RadioButton rbtn1 = (RadioButton) inflater.inflate(R.layout.main_bottom_radio_button, container, false);
        addButton(rbtn1, 1);*/
        showPointAt(3, true);
        return view;
    }

    @Override
    public List<PageInfo> createPages() {
/*
        try {
            BeanUtils.copyProperties(userBean, userBean1);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }*/


        List<PageInfo> pageList = new ArrayList<>();

        HomeMainFragment homeFragment = new HomeMainFragment();
        pageList.add(new PageInfo(homeFragment, "首页", R.drawable.ic_main_1));

        HomeQualityFragment homeFragment1 = new HomeQualityFragment();
        pageList.add(new PageInfo(homeFragment1, "精选", R.drawable.ic_main_2));

        HomeGameFragment homeFragment2 = new HomeGameFragment();
        pageList.add(new PageInfo(homeFragment2, "游戏", R.drawable.ic_main_3));

        HomeVideoFragment homeFragment3 = new HomeVideoFragment();
        pageList.add(new PageInfo(homeFragment3, "短视频", R.drawable.ic_main_4));

        Fragment mineFragment = new MineFragment();
        pageList.add(new PageInfo(mineFragment, "我的", R.drawable.ic_main_5));

        return pageList;
    }


    /**
     * 显示红点
     *
     * @param show
     */
    public void showPointAt(int position, final boolean show) {
        BadgeRadioButton rbtn = getRadioButtonAt(position);
        if (rbtn != null) {
            if (show) {
                rbtn.showPoint();
            } else {
                rbtn.hidePoint();
            }
        }
    }


}
